import requests
import re
import execjs



cookies = {
    'acw_tc': '2760827f17242927947176621e27ec3eef5557acb173b366bb09fcaf9c3acd',
    'acw_sc__v2': '66c69ebabb738bf722cf5e32cffb63ccd5a4e4e9',
    'xq_a_token': '7747107a16c7844c358ac0bbe44530ab34c16e3d',
    'xqat': '7747107a16c7844c358ac0bbe44530ab34c16e3d',
    'xq_r_token': '517f2f4c758b1e5786699e0976d627a7ee5cbf5c',
    'xq_id_token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ1aWQiOi0xLCJpc3MiOiJ1YyIsImV4cCI6MTcyNjYyMDc3OSwiY3RtIjoxNzI0MjkyNzg0NzA0LCJjaWQiOiJkOWQwbjRBWnVwIn0.i45ua3oqffBHfuRJ8W1tzv6RRfic0u_7HQzGG-sIVy2_cQgPvwdNlBl0060_EWU59mdY8NEXiC4zd6ostq5JhYTfg9NQCdVWfBvcl19_Kqej9qm2vlQBZncuTGF4EGLZmC3c6pqtkR7lwYVAa92Fy2gVJRt_H9UCOID1xGkv4F_R-ADmmIw5G5Xma3rSwln43W6EKRoLhOExmDIdkKxVi3hSE63kPhXuvoQUjWKBMbzuzNfHibT5cCISCNhhdwZql2RABRoEtMEEdMhHdiUpRCxOfpS2Uiqur_2Q1cJL1S4aGVtuR00b9MutVI4DZvmyk6h36drpOoVqs0-JBRN0RQ',
    'cookiesu': '621724292794828',
    'u': '621724292794828',
    'Hm_lvt_1db88642e346389874251b5a1eded6e3': '1724292794',
    'Hm_lpvt_1db88642e346389874251b5a1eded6e3': '1724292794',
    'HMACCOUNT': 'E3DA92CCA15F8725',
    's': 'as1ayxe7sm',
    'device_id': 'd18ea9ed1811feb777d5bd87757b8c00',
    'smidV2': '20240822101314332241e7ecf50df10ffae2fab46647b1003889d8f3636b540',
    '.thumbcache_f24b8bbe5a5934237bbc0eda20c1b6e7': 'CYfYXPXG+NnGnyhwYhVOAmSPc2Wed62qSrJgWEnMGZoG9H/wZTKevuKv7SWBbCLR+FC6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IrxWPPGDD=',
}

headers = {
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
    'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
    'Cache-Control': 'max-age=0',
    'Connection': 'keep-alive',
    # 'Cookie': 'acw_tc=2760827f17242927947176621e27ec3eef5557acb173b366bb09fcaf9c3acd; acw_sc__v2=66c69ebabb738bf722cf5e32cffb63ccd5a4e4e9; xq_a_token=7747107a16c7844c358ac0bbe44530ab34c16e3d; xqat=7747107a16c7844c358ac0bbe44530ab34c16e3d; xq_r_token=517f2f4c758b1e5786699e0976d627a7ee5cbf5c; xq_id_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ1aWQiOi0xLCJpc3MiOiJ1YyIsImV4cCI6MTcyNjYyMDc3OSwiY3RtIjoxNzI0MjkyNzg0NzA0LCJjaWQiOiJkOWQwbjRBWnVwIn0.i45ua3oqffBHfuRJ8W1tzv6RRfic0u_7HQzGG-sIVy2_cQgPvwdNlBl0060_EWU59mdY8NEXiC4zd6ostq5JhYTfg9NQCdVWfBvcl19_Kqej9qm2vlQBZncuTGF4EGLZmC3c6pqtkR7lwYVAa92Fy2gVJRt_H9UCOID1xGkv4F_R-ADmmIw5G5Xma3rSwln43W6EKRoLhOExmDIdkKxVi3hSE63kPhXuvoQUjWKBMbzuzNfHibT5cCISCNhhdwZql2RABRoEtMEEdMhHdiUpRCxOfpS2Uiqur_2Q1cJL1S4aGVtuR00b9MutVI4DZvmyk6h36drpOoVqs0-JBRN0RQ; cookiesu=621724292794828; u=621724292794828; Hm_lvt_1db88642e346389874251b5a1eded6e3=1724292794; Hm_lpvt_1db88642e346389874251b5a1eded6e3=1724292794; HMACCOUNT=E3DA92CCA15F8725; s=as1ayxe7sm; device_id=d18ea9ed1811feb777d5bd87757b8c00; smidV2=20240822101314332241e7ecf50df10ff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qwh+VWhFDG2UxpLbttGhYGVQUbeAR16VmRE=urSiWGQuh=IUUgnzP4pcQxFtQkVxjNEa7zo3Xs/53D08DiQpiOOWp=YPqb+8C0Tj5T2QBDrDieeIrxWPPGDD=',
    'Referer': 'https://xueqiu.com/today',
    'Sec-Fetch-Dest': 'document',
    'Sec-Fetch-Mode': 'navigate',
    'Sec-Fetch-Site': 'same-origin',
    'Sec-Fetch-User': '?1',
    'Upgrade-Insecure-Requests': '1',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0',
    'sec-ch-ua': '"Chromium";v="122", "Not(A:Brand";v="24", "Microsoft Edge";v="122"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
}

response = requests.get('https://xueqiu.com/today', cookies=cookies, headers=headers)
acw_tc = response.cookies.get_dict()
# print(acw_tc)
response = re.sub(r'\s','',response.text)
arg1 = re.findall("vararg1='(.*?)';",response)[0]

file = open('雪球Code.js',mode='r',encoding='utf-8').read()
acw_tc['acw_sc__v2'] = execjs.compile(file).call('getcookie',arg1)
# print(acw_tc)

response = requests.get('https://xueqiu.com/today', cookies=acw_tc, headers=headers)
print(response.text)

